package com.t01.bdqn.design.factory;

import com.t01.bdqn.design.factory.student.Student;
import com.t01.bdqn.design.factory.student.impl.MaXingHong;
import com.t01.bdqn.design.factory.student.impl.WangXin;
import com.t01.bdqn.design.factory.student.impl.YangHaoBin;

public class StudentFacotry {

    //通过工厂获取对象
    //缺点 ： 
    public static Student getInstance(){
        return new MaXingHong();
    }

    //通过工厂+参数  获取对象
    public static Student getInstanceByParam(String name){
        switch (name) {
            case "mxh":
                return new MaXingHong();
            case "wx":
                return new WangXin();
            case "yjb":
                return new YangHaoBin();
            default:
                throw new RuntimeException("无效的name：" + name + " !");
        }
    }



}
